package com.ruoyi.classscoreonmonth.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.count.domain.Studentstandardscores;
import com.ruoyi.count.mapper.StudentstandardscoresMapper;
import com.ruoyi.teacher.domain.Teacher;
import com.ruoyi.teacher.mapper.TeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.classscoreonmonth.mapper.ClassscoreonmonthMapper;
import com.ruoyi.classscoreonmonth.domain.Classscoreonmonth;
import com.ruoyi.classscoreonmonth.service.IClassscoreonmonthService;

/**
 * 班级成绩生成Service业务层处理
 * 
 * @author yxy
 * @date 2024-11-08
 */
@Service
public class ClassscoreonmonthServiceImpl implements IClassscoreonmonthService 
{
    @Autowired
    private ClassscoreonmonthMapper classscoreonmonthMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private StudentstandardscoresMapper studentstandardscoresMapper;
    /**
     * 查询班级成绩生成
     * 
     * @param id 班级成绩生成主键
     * @return 班级成绩生成
     */
    @Override
    public Classscoreonmonth selectClassscoreonmonthById(Long id)
    {
        return classscoreonmonthMapper.selectClassscoreonmonthById(id);
    }

    /**
     * 查询班级成绩生成列表
     * 
     * @param classscoreonmonth 班级成绩生成
     * @return 班级成绩生成
     */
    @Override
    public List<Classscoreonmonth> selectClassscoreonmonthList(Classscoreonmonth classscoreonmonth)
    {
        return classscoreonmonthMapper.selectClassscoreonmonthList(classscoreonmonth);
    }

    /**
     * 新增班级成绩生成
     * 
     * @param classscoreonmonth 班级成绩生成
     * @return 结果
     */
    @Override
    public int insertClassscoreonmonth(Classscoreonmonth classscoreonmonth)
    {
        classscoreonmonth.setCreateTime(DateUtils.getNowDate());
        return classscoreonmonthMapper.insertClassscoreonmonth(classscoreonmonth);
    }

    /**
     * 修改班级成绩生成
     * 
     * @param classscoreonmonth 班级成绩生成
     * @return 结果
     */
    @Override
    public int updateClassscoreonmonth(Classscoreonmonth classscoreonmonth)
    {
        return classscoreonmonthMapper.updateClassscoreonmonth(classscoreonmonth);
    }

    /**
     * 批量删除班级成绩生成
     * 
     * @param ids 需要删除的班级成绩生成主键
     * @return 结果
     */
    @Override
    public int deleteClassscoreonmonthByIds(Long[] ids)
    {
        return classscoreonmonthMapper.deleteClassscoreonmonthByIds(ids);
    }

    /**
     * 删除班级成绩生成信息
     * 
     * @param id 班级成绩生成主键
     * @return 结果
     */
    @Override
    public int deleteClassscoreonmonthById(Long id)
    {
        return classscoreonmonthMapper.deleteClassscoreonmonthById(id);
    }

    /**
     * 查询班级成绩生成列表按照老师的信息进行查询
     * @param gradeId
     * @param schoolId
     * @param classs
     * @return
     */
    @Override
    public List<Classscoreonmonth> selectClassscoreonmonthListByTeacher(String gradeId, String schoolId, String classs) {
        return classscoreonmonthMapper.selectClassscoreonmonthListByTeacher(gradeId, schoolId, classs);
    }

    @Override
    public List<Studentstandardscores> selectClassscoreonmonthListByTeacherName(String userName) {
        Teacher teacher = new Teacher();
        teacher.setTeacherid(userName);
        List<Teacher> teacher1 = teacherMapper.selectTeacherList(teacher);
        String classs = teacher1.get(0).getClassss();
        String yearAdmission = teacher1.get(0).getYearAdmission();
        String school = teacher1.get(0).getSchool();
        // 查询成绩
        Studentstandardscores studentstandardscores = new Studentstandardscores();
        studentstandardscores.setGrade(yearAdmission);
        studentstandardscores.setSchool(school);
        studentstandardscores.setClasss(classs);
        List<Studentstandardscores> studentstandardscoresList = studentstandardscoresMapper.selectStudentstandardscoresList(studentstandardscores);
        System.out.println(studentstandardscoresList);
        return studentstandardscoresList;
    }
}
